#NP1 Hello World!
print('Hello World!')

#NP2 多行输出
str2 = 'Hello Nowcoder!'
str1 = 'Hello World!'
print(str1)
print(str2)

# NP3 读入字符串
a = input()
print(a)

#NP4 读入整数数字
a = int(input())
print(a)
print(type(a))


# NP5 格式化输出（一）
a = input()
print("I am " + a + " and I am studying Python in Nowcoder!")

#NP6 牛牛的小数输出
a = float(input())
print("{:.2f}".format(a))

#NP7 小数化整数
a = float(input())  
b = int(a)
print(b)          

# NP8 为整数增加小数点
a = input()
b = float(a)
print(b)
print(type(b))

# NP9 十六进制数字的大小
a = input()
b = int(a,16)
print(b)

# NP10 牛牛最好的朋友们
a = input()
b = input()
print(a+b)

# NP11 单词的长度
a = input()
print(len(a))

#NP12 格式化输出（二）
a = input()
print(str.lower(a))
print(str.upper(a))
print(str.title(a))


# NP13 格式化输出（三）
a = input()
print(str.strip(a))

# NP14 不用循环语句的重复输出
a = input()
print(a*100)

# NP15 截取用户名前10位
a = input()
print(a[0:10])

# NP16 发送offer
offer_list = ["Allen","Tom"]
for fruit in offer_list :
    print(fruit + ", you have passed our interview and will soon become a member of our company.")
   

offer_list[1] = "Andy"
for fruit in offer_list :
    print(fruit + ", welcome to join us!")
    
#NP17 生成列表
a = input()
print(a.split( ))

#NP18 生成数字列表
a = input()
a=a.split(' ')
print([int(x) for x in a])

# NP19 列表的长度
a = input()
a = a.split(' ')
print(len(a))

# NP20 增加派对名单（一）
a = input()
a = a.split(' ')
a.append('Allen')
print(a)

# NP21 增加派对名单（二）
a = input()
a = a.split()
a.insert(0,'Allen')
print(a)

# NP22 删除简历
a = input()
a = a.split()
del a[0]
print(a)

# NP23 删除好友
a = input()
b = input()
a = a.split()
a.remove(b)
print(a)

# NP24 淘汰排名最后的学生 /// 两种
a = input()
a = a.split()
a.pop()
a.pop()
a.pop()
print(a)

a = input()
a = a.split()
for _ in range(3):
    a.pop()
print(a)

# NP25 有序的列表
my_list = ['P','y','t','h','o','n']

b = sorted(my_list)
print(b)
c = sorted(my_list , reverse = True)

print(my_list)
print(c)

#NP26 牛牛的反转列表
num = [3,5,9,0,1,9,0,3]
num.reverse()
print(num)


# NP27 朋友们的喜好
a = []
name = ['Niumei', 'YOLO', 'Niu Ke Le', 'Mona']
food = ['pizza','fish','potato','beef']
number = [3,6,0,3]
a.append(name)
a.append(food)
a.append(number)
print(a)

# NP28 密码游戏
a = input().strip()
b = [(int(c)+3)%9 for c in a]

# NP29 用列表实现栈
print(f"{b[2]}{b[3]}{b[0]}{b[1]}")    

a = [1,2,3,4,5]
a.pop()
print(a)
a.pop()
print(a)
b = int(input())
a.append(b)
print(a)

# NP30 用列表实现队列
queue = [1,2,3,4,5]
queue.pop(0)
print(queue)
queue.pop(0)
print(queue)
a = int(input())
queue.append(a)
print(queue)

# NP31 团队分组
group_list = [ 'Tom', 'Allen', 'Jane', 'William', 'Tony' ]
print(group_list[:2])
print(group_list[1:4])
print(group_list[3:])

# NP32 牛牛的加减器
a = int(input())
b = int(input())
print(a + b)
print(a - b)

# NP33 乘法与幂运算
x = int(input())
y = int(input())
print(x * y)
print(x ** y)

# NP34 除法与取模运算
x = int(input())
y = int(input())
a,b =divmod(x , y)
print(a,b)
print(f"{(x / y):.2f}")

# NP35 朋友的年龄是否相等
a, b = map(int, input().split())
print(bool(a == b))

# NP36 谁的数字大
a, b = map(int, input().split())
print(bool(a > b))
print(bool(a < b))

# NP37 不低于与不超过
k, x, y = map(float, input().split())
print(bool(k <= x))
print(bool(k >= y))

# NP38 牛牛的逻辑运算
x, y = map(int, input().split())
print(x and y)
print(x or y)
print(bool(not x))
print(bool(not y))

# NP39 字符串之间的比较
a = input()
b = input()
print(bool(a == b))
print(a.lower() == b.lower())

# NP40 俱乐部的成员
a = input().split()
b = input()
if b in a:
    print('True')
else:
    print('False')

# NP42 公式计算器
x, y, z, k  = map(int,input().split())
print((x + y) * (z - k))

# NP43 判断布尔值
a = input()
if int(a) == 0:
    print('Erros!')
else :
    print('Hello World!')

#NP44 判断列表是否为空
    my_list = []
if not my_list :
    print('my_list is empty!')
else:
    print('my_list is not empty!')

# NP49 字符列表的长度
my_list = ['P','y','t','h','o','n']
print('Here is the original list:')
print(my_list)
print()
print('The number that my_list has is:')
print(len(my_list))

# NP45 禁止重复注册
current_users = ['Niuniu','Niumei','GURR','LOLO']
new_users = ['GurR','Niu Ke Le','LoLo','Tuo Rui Chi']
current_lower = [a.lower() for a in current_users]

for a in new_users:
    if a.lower() in current_lower:
        print(f'The user name {a} has already been registered! Please change it and try again!')
    else:
        print(f'Congratulations, the user name {a} is available!')

# NP46 菜品的价格
a = input()
if a == 'pizza':
    print('10')
elif a == 'rice':
    print('2')
elif a == 'yogurt':
    print('5')
else :print('8')

# NP47 牛牛的绩点
zidian = {
    'A' : 4.0,
    'B' : 3.0,
    'C' : 2.0,
    'D' : 1.0,
    'F' : 0 
}
sum_value = 0
c = 0.0

while True :
    a = input()
    if a == 'False':
        break
    d = float(input())
    b = zidian.get(a)
    sum_value += d * b 
    c += d 

print(f'{sum_value/c:.2f}')

# NP48 验证登录名与密码
a = input()
b = input()
if a =='admis' and b == 'Nowcoder666':
    print('Welcome!')
else :
    print('user id or password is not correct!')

# NP49 字符列表的长度
my_list =['P','y','t','h','o','n']
print('Here is the original list:')
print(my_list)
print()
print('The number that my_list has is:')
print(len(my_list))

# NP50 程序员节
user_list = ['Niuniu' ,'Niumei' , 'Niu Ke Le']
for a in user_list:
    print(f'Hi, {a}! Welcome to Nowcoder!')
print("Happy Programmers' Day to everyone!")

# NP51 列表的最大与最小
a_list = []
for b in range(10,51):
    a_list.append(b)
print(a_list)
print(a_list[0], a_list[len(a_list)-1])

# NP52 累加数与平均值
age_list = list(map(int,input().split()))
sum = 0
count = 0
for a in age_list:
    sum += a
    count +=1
print(f'{sum} {sum/count:.1f}')

# NP53 前10个偶数
my_list = list(range(0 , 20, 2))
for a in my_list:
    print(a)

# NP54 被5整除的数字

# NP55 2的次方数
my_list = []
for a in range(1,11):
    my_list.append(2**a)
for a in my_list:
    print(a)

# NP56 列表解析
a = [i for i in range(0 , 10)]
print(a)

# NP57 格式化清单
a_list= ['apple', 'ice cream', 'watermelon', 'chips', 'hotdogs', 'hotpot']
while a_list:
    a_list.pop()
    print(a_list)

# NP58 找到HR
users_list = ['Niuniu','Niumei','HR','Niu Ke Le','GURR' , 'LOLO' ]
for a in users_list:
    if a =='HR':
        print('Hi, HR! Would you like to hire someone?')
    else:
        print(f'Hi, {a}! Welcome to Nowcoder!')

# NP59 提前结束的循环
a_list = [3, 45, 9, 8, 12, 89, 103, 42, 54, 79]
x = int(input())
for i in a_list:
    if i == x:
        break
    else:
        print(i)
# NP60 跳过列表的某个元素
for a in range(1,16):
    if a == 13:
        continue
    else:
        print(a, end=' ')

# NP61 牛牛的矩阵相加
a = [[1,2,3],[4,5,6],[7,8,9]]
n =int(input())
b = []
for i in a:
    b.append([c * n for c in i])
print(b)

# NP62 运动会双人项目
a = input()
b = input()
c = tuple((a , b))
print(c)

# NP63 修改报名名单
entry_form = tuple(('Niuniu', 'Niumei'))
print(entry_form)
try:
    entry_form[1] = 'Niukele'
except TypeError:
    print('The entry form cannot be modified!')

# NP64 输出前三同学的成绩
a = tuple(input().split())
print(a[:3])

# NP65 名单中出现过的人
a = tuple(['Tom', 'Tony', 'Allen', 'Cydin', 'Lucy', 'Anna'])
name = input()
tmp = 0
print(a)
for i in a:
    if name == i:
        print('Congratulations!')
        tmp = 1 
if tmp == 0:
    print('What a pity!')

# NP66 增加元组的长度
a = tuple(range(1,6))
print(a)
print(len(a))
b = tuple(a + tuple(range(6,11)))
print(b)
print(len(b))

# NP67 遍历字典

# NP68 毕业生就业调查
survey_list = ('Niumei','Niu Ke Le','GURR','LOLO')
result_dict = {
    'Niumei': 'Nowcoder',
    'GURR': 'HUAWEI'
}
#a = result_dict{}.split()
for i in survey_list:
    if i in result_dict:
        print(f'Hi, {i}! Thank you for participating in our graduation survey!')
    else :
        print(f'Hi, {i}! Could you take part in our graduation survey?')

# NP69 姓名与学号

my_dict_1 = {'name': 'Niuniu','Student ID': 1}
my_dict_2 = {'name': 'Niumei','Student ID': 2}
my_dict_3 = {'name': 'Niu Ke Le','Student ID': 3}
dict_list = []
dict_list.append(my_dict_1)
dict_list.append(my_dict_2)
dict_list.append(my_dict_3)
for i in dict_list:
    print(f"{i['name']}'s student id is {i['Student ID']}.")
    
# NP70 首都
cities_dict ={
    'Beijing': {'Capital': 'China'},
    'Moscow': {'Capital': 'Russia'},
    'Paris': {'Capital': 'France'}
}
for i in sorted(cities_dict):
    b = cities_dict[i]['Capital']
    print(f'{i} is the capital of {b}!')

# NP71 喜欢的颜色
result_dict = {
    'Allen': ['red', 'blue', 'yellow'],
    'Tom': ['green', 'white', 'blue'],
    'Andy': ['black', 'pink']
}
for i in sorted(result_dict):
    print(f"{i}'s favorite colors are:")
    for a in result_dict[i]:
        print(a)

# NP72 生成字典
a = input().split()
b = input().split()
c = dict(zip(a , b))
print(c)

# NP73 查字典
a = {
    "a": ["apple", "abandon", "ant"],
    "b": ["banana", "bee", "become"],
    "c": ["cat", "come"],
    "d": "down",
}
b = input()
for b in a[b]:
    
     print(b , end = ' ')

# NP74 字典新增

a = {
    "a": ["apple", "abandon", "ant"],
    "b": ["banana", "bee", "become"],
    "c": ["cat", "come"],
    "d": "down",
}
b = input()
c = input()
a[b] = c
print(a)

# NP75 使用字典计数

a = input()
b = {}
for i in a:
    b[i] = b.get(i,0) + 1
print(b)

# NP76 列表的最值运算

# NP77 朋友的年龄和
a = list(map(int , input().split()))
print(sum(a))

# NP78 正数输出器

a = int(input())
print(abs(a))

# NP79 字母转数字

a = input()
print(ord(a))

# NP80 数字的十六进制

a = int(input())
print(hex(a))

# NP81 数字的二进制表示
a = int(input())
print(bin(a))

# NP82 数学幂运算
x, y = map(int,input().split())

print(x ** y)
print(pow(y , x))

# NP83 错误出现的次数

a = list(map(int , input().split()))

print(a.count(0))

# NP84 列表中第一次出现的位置

a = input().split()
print(a.index('NiuNiu'))

# NP85 字符的类型比较
a = input()
print(a.isalpha())
print(a.isdigit())
print(a.isspace())

# NP86 字符子串的查找
long_str = input()
print(long_str.find('NiuNiu'))

# NP87 子串的数量
patten = input()
print(patten.count('Niu'))

# NP88 句子拆分
a = input()
print(a.split())

# NP89 单词造句
word = []
while True :
    a = input()
    if a == '0':
        break
    word.append(a)
print(' '.join(word))

# NP90 修正错误的字母
a = input()
print(a.replace('a*','ab'))

# NP91 小数位修正
a = float(input())
print(round(a , 2))

# NP92 公式计算器
print(eval(input()))

# NP93 创建集合
a = set(input().split())
print(sorted(a ))

# NP94 函数求差
a = int(input())
b = int(input())
def cal(a , b):
    print(a-b)
    print(b-a)

    return 
cal(a , b)

# NP95 兔子的数量

n = int(input())
def f(n):
    if n ==1:
        return 2
    if n ==2:
        return 3
    
    return f(n-1) + f(n-2)
print(f(n))

# NP96 球的表面积
import math
r = [1, 2, 4, 9, 10, 13]
def V(r):
    v = 4 * math.pi * r * r
    return v
for i in r:
    print(f'{V(i):.2f}')

# NP97 班级管理


class Student:
    def __init__(self ,name , id , score, a):
        self.name = name
        self.id = id
        self.score = int(score)
        self.a = a
    def ps(self):
        print(f"{self.name}'s student number is {self.id}, and his grade is {self.score}. He submitted {len(self.a)} assignments, each with a grade of {' '.join(self.a)}")

name = input()
id = input()
score = int(input())
a = input().split()
x = Student(name , id , score , a)
x.ps()

# NP98 修改属性1

class Employee():
    def __init__(self, name , salary  ):
        self.name = name
        self.salary = salary 
        # self.age = int(age)
    def printclass(self):
        try:
            print(f"{self.name}'salary is {self.salary}, and his age is {self.age}")
        except AttributeError:
              print("Error! No age")
name = input()
salary = input()
age = input()
e = Employee(name , salary)
e.printclass()
e.age = age
e.printclass()

# NP99 修改属性2

class Employee:
    def __init__(self, name , salary) -> None:
        self.name = name
        self.salary = salary
    def printclass(self):
        print(f"{self.name}'salary is {self.salary}, and his age is {self.age}")
    
    def hasattr(self):
        try :
            self.age 
            print('True')
            self.printclass(self)
        except AttributeError:
            print('False')
            setattr(x,'age',age)
            self.printclass()

name = input()
salary = input()
age = input()
x = Employee(name , salary)
x.hasattr()